package kr.hyosang.android.penfo.parser;

import kr.hyosang.android.penfo.Definition;

public class LoginParser extends Parser<String[]>
{
    @Override
    public String[] parse(String data)
    {
        //로그인 성공시 <meta http-equiv="refresh" content="0; url=/"> 한줄 내려옴.
        String redirectStr = "<meta http-equiv=\"refresh\" content=\"0; url=/\">";
        
        String [] result = new String[2];
        
        if(data.indexOf(redirectStr) >= 0) {
            //로그인 성공
            result[0] = Definition.KEY_OK;
            result[1] = "";
        }else {
            String mesg = getSubContent(data, "<td align=center height=30 style=\"font-family:Tahoma;font-size:8pt;\">", "<center>");
            mesg = getSubContent(mesg, "<br>", "<br>");
            
            result[0] = Definition.KEY_FAIL;
            result[1] = mesg;
        }
        
        return result;
    }
}
